import 'package:flutter/material.dart';
import 'dart:ui';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: Scaffold(
          body: Stack(
            children: <Widget>[
              ConstrainedBox(
                //约束盒子
                constraints: const BoxConstraints.expand(),
                child: Image.asset("assets/images/demo.jpg"),
              ),
              Center(
                child: ClipRect(
                  //可裁切矩形
                  child: BackdropFilter(
                    //背景过滤器
                    filter: ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
                    child: Opacity(
                      opacity: 0.5,
                      child: Container(
                        width: 500.0,
                        height: 700.0,
                        decoration: BoxDecoration(color: Colors.grey.shade200),
                        child: Center(
                          child: Text(
                            "毛玻璃效果",
                            style: Theme.of(context).textTheme.display3,
                          ),
                        ), //盒子修饰器
                      ),
                    ),
                  ),
                ),
              )
            ],
          ),
        ));
  }
}
